package org.karson.designpattern.behavioral.memento.text;

/**
 * @author Karson Wang
 * @title InputText
 * @Description 描述
 * @Date 2020/4/16 19:51
 * @Copyright 2019-2020
 */
public class InputText {

    private StringBuilder text = new StringBuilder();

    public String getText() {
        return text.toString();
    }

    public void append(String input) {
        text.append(input);
    }

    public Snapshot createSnapshot() {
        return new Snapshot(text.toString());
    }

    public void restoreSnapshot(Snapshot snapshot) {
        this.text.replace(0, this.text.length(), snapshot.getText());
    }
}